package com.neusoft.news.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.neusoft.news.bean.News;
import com.neusoft.news.utils.JDBCUtils;

public class NewsExamineDao {
    
	public List<News> selectAllNews() {
		List<News> newslist = new ArrayList<News>();		
		try {
			Connection conn=JDBCUtils.getConnection();
			String sql = "select * from d_news where news_state=0";
			PreparedStatement pst = conn.prepareStatement(sql);
			ResultSet rs = pst.executeQuery();
			while(rs.next()){
				News news = new News(
						rs.getString(1),rs.getString(2),
						rs.getString(3),rs.getString(4),
						rs.getString(5),rs.getString(6),
						rs.getString(7),rs.getString(8),
						rs.getString(9),rs.getString(10),
						rs.getString(11)
						);
				newslist.add(news);
			}
		} catch (SQLException | ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return newslist;
	}

}
